import React from 'react';
import { Redirect, Route } from 'react-router-dom'
let isLogin = true;
let userLevel = 112;
class Protect extends React.Component {
  // componentWillUnmount() {
  //   console.log("离开了" + this.props.path)
  // }
  componentDidMount() {
    console.log(666)
  }
  render() {
    let { path, component: Comp, level = 0, ...qqq } = this.props;
    return <>
      <Route path={path} render={(props) => {
        console.log(props)
        if (isLogin) {
          if (userLevel >= level) {
            return <Comp {...props} {...qqq} />
          } else {
            return <Redirect to='/404'></Redirect>
          }

        } else {
          return <Redirect to='/login'></Redirect>
        }
      }}></Route>
    </>;
  }
}
export default Protect